﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using Common.Library;
using OnlineVideos.UI;

namespace OnlineVideos.Views
{
    public partial class SaveFolderName : PhoneApplicationPage
    {
        IsolatedStorageFile isoStore = IsolatedStorageFile.GetUserStoreForApplication();
        public SaveFolderName()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(SaveFolderName_Loaded);
        }
        void SaveFolderName_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                FlurryWP8SDK.Api.LogEvent("SaveFolderName Page", true);
            }
            catch (Exception ex)
            {
                
                 Exceptions.SaveOrSendExceptions("Exception in SaveFolderName_Loaded event In SaveFolderName.cs file.", ex);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AppSettings.DownloadedFolderName = txtfoldername.Text;
                if (!isoStore.DirectoryExists(ResourceHelper.ProjectName + "/" + AppSettings.DownloadedFolderName))
                {

                    NavigationService.Navigate(new Uri("/Views/ShowList.xaml?index=" + 2, UriKind.Relative));
                    // close();
                }
                else
                {
                    MessageBox.Show("The Folder Already Exists");
                }
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in button1_Click event In SaveFolderName.cs file.", ex);
            }
        }
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                FlurryWP8SDK.Api.EndTimedEvent("SaveFolderName Page");
              
            }
            catch (Exception ex)
            {

                Exceptions.SaveOrSendExceptions("Exception in OnNavigatedFrom Method In SaveFolderName.cs file.", ex);
            }
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            try
            {
                FlurryWP8SDK.Api.LogPageView();
                NavigationService.RemoveBackEntry();
            }
            catch (Exception ex)
            {
                
               Exceptions.SaveOrSendExceptions("Exception in OnNavigatedTo Method In SaveFolderName.cs file.", ex);
            }
        }


        private void imgTitle_MouseEnter(object sender, MouseEventArgs e)
        {
            NavigationService.Navigate(NavigationHelper.MainPanoramaPage);
        }
    }
}